<h2><%= t('images') %></h2>
<%=error_message_on :viewable, :images %>
<table class="index" style="width: 98%;">
  <tr>
    <th><%= t('image') %></th>
    <th><%= t('action') %></th>
  </tr>
  <% viewable.images.each do |image| %>
  <tr>
    <td><%= image_tag image.attachment.url(:small) %></td>
    <td>
      <%= link_to_remote t('delete'),
          :url => admin_image_url(image),
          :method => 'delete',
          :before => "Element.show('img_busy_indicator')",
          :complete => "Element.hide('img_busy_indicator')",
          :confirm => t("are_you_sure_delete_image"),
          :update => 'image-listing' %>
      <%= image_tag "spinner.gif", :plugin=>"spree", :style => "display:none", :id => 'img_busy_indicator' %>
    </td>
  </tr>
  <% end %>
  <% if viewable.images.empty? %>
    <tr>
      <td colspan="3"><%= t('none_available') %>.</td>
    </tr>
  <% end %>
</table>
<p>
  <%= button_link_to_function t("new_image"), "$('new-img-link').hide();$('new-image').show()", :icon => 'add', :id => "new-img-link" %><br/><br/>
</p>
<table id="new-image" style="display:none">
  <% fields_for :image do |image| %>
    <tr>
      <td><%= t("filename") %>:</td>
      <td><%= image.file_field :attachment, :size => 150 %></td>
    </tr>
  <% end %>
</table>